<%@ page import="model.*" %>
<%@ include file="header.tpl.jsp" %>

<%Paper[] plist = (Paper[]) request.getAttribute("plist[]");%>
<%String[] ulist = (String[]) request.getAttribute("ulist[]");%>

<div class="box list">
	<h2>Paper List</h2>
	<div class="head_actions">
	<%if(user.getGroup().hasPermission(UserGroup.ADD_PAPER)){%>
		<a href="EditPaper">[Add a New Paper]</a>
	<%}%>
	</div>
	
	<table>
		<thead>
			<tr><td>Paper Title</td><td>Score in Total</td><td>Author</td><td>Operation</td></tr>
		</thead>
		<tbody>
		<%for(int i = 0; i < plist.length; i++){%>
		<%Paper p = plist[i];%>
			<tr>
				<td><%=p.getTitle()%></td>
				<td><%=p.getTotalScore()%></td>
				<td><%=ulist[i]%></td>
				<td>
				<%if(user.getGroup().hasPermission(UserGroup.ANSWER_QUESTION)){%>
					<a href="QuestionList?pid=<%=p.getPid()%>">[Try it!]</a>
				<%}%>
				<%if(user.getGroup().hasPermission(UserGroup.EDIT_PAPER)){%>
					<a href="EditPaper?pid=<%=p.getPid()%>">[Edit]</a>
				<%}%>
				<%if(user.getGroup().hasPermission(UserGroup.DELETE_PAPER)){%>
					<a href="DeletePaper?pid=<%=p.getPid()%>">[Delete]</a>
				<%}%>
					<a href="RankList?pid=<%=p.getPid()%>">[Rank]</a>
				</td>
			</tr>
		<%}%>
		</tbody>
	</table>
</div>

<%=request.getAttribute("mpage")%>

<%@ include file="footer.tpl.jsp" %>